<!DOCTYPE html>
<!--
To change this license header, choose License Headers in Project Properties.
To change this template file, choose Tools | Templates
and open the template in the editor.
-->
<html>
<head>
<script type="text/javascript" charset="utf-8"
	src="<?php echo Yii::app()->baseUrl?>/kindeditor/kindeditor-min.js"></script>
<script type="text/javascript" charset="utf-8"
	src="<?php echo Yii::app()->baseUrl?>/layer/layer.js"></script>
<script type="text/javascript"
	src="<?php echo Yii::app()->baseUrl?>/kindeditor/h5Client.js"></script>
<link rel="stylesheet"
	href="http://kindeditor.net/ke4/themes/default/default.css"
	type="text/css" />
<style>
.msg_top {
	background-color: #CD853F;
	text-align: center;
	/*                vertical-align: middle;*/
	border-radius: 5px;
	-webkit-border-radius: 5px;
	-moz-border-radius: 5px;
	border-bottom-right-radius: 0px;
	border-bottom-left-radius: 0px;
}

.msg_bottom {
	border-radius: 5px;
	-webkit-border-radius: 5px;
	-moz-border-radius: 5px;
	border-top-right-radius: 0px;
	border-top-left-radius: 0px;
}

.msg_li_div {
	background-color: #CDAD00;
	text-align: center;
	border-radius: 5px;
	-webkit-border-radius: 5px;
	-moz-border-radius: 5px;
}

.i_ul_rel {
	display: block;
	padding: 0 0 0 14px;
	left: -10px;
	position: relative;
	list-style-type: none;
}

.i_li_left {
	padding-left: 5px;
	width: 50%;
	position: relative;
	margin-bottom: 6px;
	box-sizing: border-box;
	-moz-box-sizing: border-box;
	-webkit-box-sizing: border-box;
	float: left;
}
</style>
<script>
function vote(id){
    if(isWeiXin()==true)
        {
	    	alert('投票需通过"智慧烟台"app,登入成功后即可参加投票！');
	    	window.location.href="http://www.zhyantai.com/folder53/index.html";
	    	return false;
        }
    else
    {
    	hgClient.getUserInfo(function(response) {
            var userInfo = response && (response.userInfo || response)|| '';
 			userInfo = jQuery.parseJSON(JSON.stringify(userInfo));
 			var userTokenKey = userInfo.userTokenKey;
 			var app_user_id = userInfo.userid;
 			
 			if (userTokenKey == null ||userTokenKey.length == 0)
 			{
 				hgClient.goLogin();
 				return false;
 			}
 			else
 			{
				var _json = jQuery.param({
  					"id" : id,
  					"app_user_id" : app_user_id,
  					"openid" : device_token								
  				});
	 	        var url='<?php echo Yii::app()->baseUrl?>/index.php/default/set_vote';
	 	         
	 	            jQuery.ajax(
	    	 	            {
	    	 	             'url':url,
	        	 	         'type':'POST',
 	        	 	         'async' : false,
   	        	 	         'data':_json,
   	        	 	         'dataType':'json',
       	        	 	     'cache':false,
    	 	                 'complete':function(data){
 	 	              		 var dic = data.responseText;
	 	                    if(dic=="每天只能投一票，谢谢。"){
	 	                        layer.alert(dic, {icon: 7},function(index){  
	 	                        location.reload();
	 	                        }); 
	 	                    }else{
	 	                        layer.alert(dic, {icon: 6},function(index){  
	 	                        location.reload();
	 	                        });                         
	 	                    }
	 	                }
 	 	            });
	 	            return false;        
 			}
		});
	}
}
            function isWeiXin(){
                var ua = window.navigator.userAgent.toLowerCase();
                if(ua.match(/MicroMessenger/i) == 'micromessenger' || ua.match(/QQ/i) == "qq"){
                    return true;
                }else{
                    return false;
                }
            }
            var device_token='';
	        $(function () {
	        	hgClient.getSystemInfo(function( response ){//获取设备信息
					var systemInfo = response.deviceInfo || response;
					systemInfo = jQuery.parseJSON(JSON.stringify(systemInfo));
		     		device_token = systemInfo.device_token;
				});
	        });
        </script>
</head>
<body style="background-color: #EEEEEE;">
	<!--中间大图-->
	<div>
		<img style="width: 100%; height: 25%"
			src="<?php echo Vote::model()->findByPk(1)->head_image;?>" />
	</div>
	<div class="msg_bottom"
		style="background-color: #F0F8FF; margin-left: 10px; margin-right: 10px; margin-bottom: 40px;">
		<div class="msg_top" style="height: 40px;">
			<span style="color: #FFFFFF; font-size: 18px; line-height: 40px;"><?php echo CHtml::encode($model->id);?>号 <?php echo CHtml::encode($model->username);?></span>
		</div>
		<div>
			<ul class="i_ul_rel">
				<li class="i_li_left">
					<div class="msg_li_div">
						<div>
							<span style="color: #FFFFFF; font-size: 18px;"><?php echo CHtml::encode($model->number);?><span
								style="color: #000000;">票</span></span>
						</div>
						<div></div>
					</div>
				</li>
				<li class="i_li_left">
					<div class="msg_li_div">
						<div>
							<span style="font-size: 18px;">当前排名<span style="color: #FFFFFF;"><?php echo CHtml::encode($row);?></span></span>
						</div>
					</div>
				</li>
			</ul>
		</div>
		<div>
			<span style="font-size: 15px; color: #CD853F; margin-left: 20px;">企业简介：</span>
			<img src="<?php echo $model->head_image;?>"
				style="width: 100%; padding-left: 20px; padding-right: 20px;"> <span
				style="font-size: 15px; color: #CD853F; margin-left: 20px;"><?php echo $model->remark;?></span>
		</div>
		<div style="text-align: center; margin-top: 15px;">
			<button onclick="vote(<?php echo $model->id;?>)" id="vote"
				type="button" class="am-btn am-btn-danger am-round"
				style="width: 250px;">投票</button>
		</div>
	</div>
</body>
</html>